/**
 * 
 */
package com.kth.subtranslator.ui;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

import javax.swing.JButton;

/**
 * @author Kevin Thackray
 *
 */
public class PlayButton extends JButton {
	
	private Color disabledColor = new Color(99, 22, 255);
	private Color enabledColor = new Color(74, 18, 189);

	/* (non-Javadoc)
	 * @see javax.swing.JComponent#paint(java.awt.Graphics)
	 */
	@Override
	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		Graphics2D g2 = (Graphics2D)g;
		RenderingHints hints = new RenderingHints(
				RenderingHints.KEY_ANTIALIASING,
				RenderingHints.VALUE_ANTIALIAS_ON
				);
		g2.setRenderingHints(hints);
		
		int pos = 6;
		int xShadowShift = 3;
		int yShadowShift = 3;
		int xShadowPos = pos + xShadowShift;
		int yShadowPos = pos + yShadowShift;
		int w = getWidth() - (pos*2);
		int h = getHeight() - (pos*2);

//		g.setColor(Color.DARK_GRAY);
//		g.fillRoundRect(xShadowPos, yShadowPos, w, h, 10, 10);
		
		if ( (isRolloverEnabled() && model.isRollover()) || !isEnabled()) {
			g.setColor(disabledColor);
		}
		else {
			g.setColor(enabledColor);
		}
		
//		g.fillRoundRect(pos, pos, w, h, 10, 10);
//		g.fill3DRect(x, y, width, height, raised)
		int[] xPoints = new int[] {pos, w, pos, pos};
		int[] yPoints = new int[] {pos, getHeight()/2, getHeight()-pos-2, pos};
		g.drawPolyline(xPoints, yPoints, 4);
		
	}

	/* (non-Javadoc)
	 * @see javax.swing.AbstractButton#paintBorder(java.awt.Graphics)
	 */
	@Override
	protected void paintBorder(Graphics g) {
		super.paintBorder(g);
	}
}